// import { createSlice } from '@reduxjs/toolkit';

const userSlice = createSlice({
	name: 'user',
	initialState: {
		user: null,
		token: null,
	},

	reducers: {
		setUser(state, action) {
			state.user = action.payload;
		},
		setToken(state, action) {
			state.token = action.payload;
		},
	},
});
// 异步函数
export const register = () => async (dispatch) => {
	// const res = await registerApi();
	// dispatch(setUser(res.data));
	// dispatch(setToken(res.data.token));
	// return res;
};

export const { setUser, setToken } = userSlice.actions;
export default userSlice;
